/*
 * @Description: 
 * @Author: 张民鸿
 * @Date: 2021-10-11 11:13:17
 * @FilePath: /cloud-register-business/Users/zhang/Desktop/zhang/zhang-cli/src/routes/routeData.tsx
 * @LastEditTime: 2023-04-03 16:22:08
 * @LastEditors: zhangminhong zhangminhong@zhujia360.com
 */
import welcome from '@/pages/welcome';
import React, { lazy } from 'react';
const Home = lazy(() => import('@/pages/home'));
import DefaultConfig from '../config.default'
//获取route后缀文件

const files = import.meta.glob('./*.route.ts', { eager: true })
console.log(files)
let configRoute: any[] = []
let keys = Object.keys(files)
keys.map((filename) => {
  // files[name] = context[filename].default
  console.log(files[filename].router)
  configRoute = [...configRoute, ...files[filename].router]
})
export interface routesConfigItem {
  path?: string
  exact?: boolean
  strict?: boolean
  component?: React.ReactNode
  selected?: string
  children?: routesConfigItem[]
  redirect?: string
  from?: string
  to?: string
}

const routes: routesConfigItem[] = [
  ...configRoute,
  {
    from: "/",
    redirect: DefaultConfig.defaultPage,
    exact: true
  },
  {
    path: "/home",
    exact: true,
    component: Home,
    selected: 'home'
  },
  {
    path: "/welcome",
    exact: true,
    component: welcome,
    selected: 'welcome'
  },
];


export default routes